package com.shelpe.services.algorithm.entity.mongo;

import java.util.Date;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import com.shelpe.services.algorithm.client.RankClient;
import com.shelpe.services.algorithm.entity.jpa.Tactics;
import com.shelpe.services.algorithm.entity.jpa.WantRank;

import lombok.Data;

@Data
@Document(collection="keyword_ranking_log")
public class KeywordRankingLog {
	@Id
	private String id;
	
	private Tactics tactics;
	private WantRank rank;
	private RankClient.KeywordRealtimeRankItem currentRank;
	private String action;
	private KeywordSnapshot keyword;
	
	@Indexed
	private long keywordID;
	@Indexed
	private long userID;
	@Indexed
	private long tacticsID;
	@Indexed
	private Date logTime;
	
	private boolean result;
	
	public void setupID(long keywordID, Date time){
		this.id = keywordID + "-" +DateFormatUtils.format(time, "yyyyMMddHHmm");
	}
	
	@Data
	public static class KeywordSnapshot{
		private long keywordID;
		private String word;
		private int maxPrice;
		private int maxMobilePrice;
		private int newMaxPrice;
		private int newMobilePrice;
	}
}
